﻿using Microsoft.AspNetCore.Authorization;
using ServiceCore.Entity;

namespace ServiceCore.WebApi.jwt
{
    [Authorize(policy: "Account")]
    public class ApiJwtController : ApiBaseController
    {
        /// <summary>
        /// 用户信息
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        protected JwtUserInfo GetJwtUserInfo()
        {
            var claims = User.Claims.ToList();
            var userid = claims.FirstOrDefault(p => p.Type == "userid")?.Value;
            if (string.IsNullOrEmpty(userid))
                return null;
            return JwtUserFileService.GetCacheUsers(userid);
        }
    }
}
